package com.icexxx.prime;

public class Main2 {

    public static void main(String[] args) {
        int n = 100000000;
        long t1 = System.currentTimeMillis();
        int count = 0;
        for (int i = 2; i < n; i++) {
            if (isPrime(i)) {
                count++;
            }
        }
        long t2 = System.currentTimeMillis();
        System.out.println("count=" + count);
        System.out.println("time=" + (t2 - t1));
    }

    private static boolean isPrime(int num) {
        int sqrtNum = (int) (Math.sqrt(num) + 1);
        for (int i = 2; i < sqrtNum; i++) {
            if (num % i == 0) {
                return false;
            }
        }
        return true;
    }

}
//count=1229
//time=0
//count=9592
//time=16
//count=78498
//time=406
//count=78498
//time=390
//count=664579
//time=11092
//count=5761455
//time=314933
